import { fetchPost, fetchGet, fetchUpload } from "@/modules/request";

const test = {
  testApi: (data) => fetchPost("api/user/test", data),
};

const userApi = {
  userLogin: (data) => fetchPost("api/user/login", data),
  touristLogin: (data) => fetchPost("api/user/touristLogin", data),
  userRegister: (data) => fetchPost("api/user/register", data),
  userInfo: (data) => fetchPost("user/getUserInfo", data),
  getOptionalList: (data) => fetchPost("user/getOptionalList", data),
  isOptional: (data) => fetchPost("user/isOptional", data),
  addOptional: (data) => fetchPost("user/addOptional", data),
  delOptionalById: (data) => fetchPost("user/delOptionalById", data),
  getRechargeList: (data) => fetchPost("user/getRechargeList", data),
  getWithdrawalListByUserId: (data) =>
    fetchPost("user/getWithdrawalListByUserId", data),
  getTradeList: (data) => fetchPost("user/getTradeList", data),
  getTradeListNoSettle: (data) => fetchPost("user/getTradeListNoSettle", data),
  upload: (data) => fetchUpload("user/upload", data),
  authentication: (data) => fetchPost("user/authentication", data),
  addBank: (data) => fetchPost("user/addBank", data),
  getBankListByUserId: (data) => fetchPost("user/getBankListByUserId", data),
  getWalletList: (data) => fetchPost("user/wallet/getWalletList", data),
  getExchangeRate: (data) => fetchPost("user/wallet/getExchangeRate", data),
  exchangeCoin: (data) => fetchPost("user/wallet/exchangeCoin", data),
  logout: (data) => fetchPost("user/out", data),
};

const marketApi = {
  cateList: (data) => fetchGet("api/user/getCateList", data),
  marketList: (data) => fetchGet("api/user/getGoodsByCate", data),
  getPriceByName: (data) => fetchGet("api/user/getPriceByName", data),
  getSecondsConfig: (data) => fetchGet("user/getSecondsConfig", data),
  addSeconds: (data) => fetchGet("user/addSeconds", data),
  getSecondsById: (data) => fetchGet("user/getSecondsById", data),
  getLeverList: (data) => fetchGet("user/contract/getLeverList", data),
  getContractConfig: (data) =>
    fetchGet("user/contract/getContractConfig", data),
  buyContract: (data) => fetchGet("user/contract/buyContract", data),
  getContractNoFinish: (data) =>
    fetchGet("user/contract/getContractNoFinish", data),
  getPositionList: (data) => fetchGet("user/contract/getPositionList", data),
  sellUserPosition: (data) => fetchGet("user/contract/sellUserPosition", data),
  revokeContract: (data) => fetchGet("user/contract/revokeContract", data),
};

const publicApi = {
  publicNews: (data) => fetchPost("api/news/list", data),
  getHelpList: (data) => fetchPost("api/user/getHelpList", data),
};

const fundsApi = {
  getFinancial: (data) => fetchPost("user/wallet/getFinancial", data),
  buyFinancial: (data) => fetchPost("user/wallet/buyFinancial", data),
  addBreach: (data) => fetchPost("user/wallet/addBreach", data),
  getBreachAmt: (data) => fetchPost("user/wallet/getBreachAmt", data),
  getUserFinancialInfo: (data) =>
    fetchPost("user/wallet/getUserFinancialInfo", data),
  getFinancialHistory: (data) =>
    fetchPost("user/wallet/getFinancialHistory", data),
};

const loansApi = {
  addLoan: (data) => fetchPost("user/loan/addLoan", data),
  getLoan: (data) => fetchPost("user/loan/getLoan", data),
  addLoanHistory: (data) => fetchPost("user/loan/addLoanHistory", data),
  addLoanRepay: (data) => fetchPost("user/loan/addLoanRepay", data),
  getLoanHistory: (data) => fetchPost("user/loan/getLoanHistory", data),
  getInterest: (data) => fetchPost("user/loan/getInterest", data),
  getLoanRepay: (data) => fetchPost("user/loan/getLoanRepay", data),
};

export { test, userApi, publicApi, marketApi, fundsApi, loansApi };
